package com.alibaba.algo.cooperation.common;


import lombok.Getter;
import lombok.Setter;

/**
 * 返回结果
 */
@Setter
@Getter
public class BaseResult<T> {
    protected Integer code;
    protected String message;
    protected T data;

    public  BaseResult(){

    }

    public BaseResult(Integer code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public static BaseResult buildSuccess() {
        return new BaseResult(SysConstant.OK, "", null);
    }

    public static BaseResult buildSuccess(String message, Object data) {
        return new BaseResult(SysConstant.OK, message, data);
    }

    public static <T> BaseResult<T> buildSuccess(Object data) {
        return new BaseResult(SysConstant.OK, "success", data);
    }



    public static BaseResult buildError(Integer code, Object data) {
        return new BaseResult(code, "", data);
    }

    public static BaseResult buildError(Integer code, String message) {
        return new BaseResult(code, message, null);
    }

    public static BaseResult buildError(Integer code, String message, Object data) {
        return new BaseResult(code, message, data);
    }

    public static BaseResult buildError(String message) {
        return new BaseResult(SysConstant.SYS_ERROR, message, null);
    }

}